<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ page import="java.util.List" %>
<%@ page import="com.milk.entity.Orders" %>
<html>
<head>
    <title>订单管理</title>
</head>
<body>
<h2>订单管理</h2>
<a href="<%=request.getContextPath()%>/orders/add">添加订单</a>
<form action="<%=request.getContextPath()%>/orders/search" method="get">
    <label for="searchUserName">搜索订单：</label><input type="text" id="searchUserName" name="searchUserName"><br>
    <input type="submit" value="搜索">
</form>
<table border="1">
    <tr>
        <th>ID</th>
        <th>用户名</th>
        <th>联系电话</th>
        <th>下单时间</th>
        <th>订单状态</th>
        <th>饮品ID列表</th>
        <th>操作</th>
    </tr>
    <%
        List<Orders> orders = (List<Orders>) request.getAttribute("orders");
        if (orders != null) {
            for (Orders order : orders) {
    %>
    <tr>
        <td><%=order.getId()%></td>
        <td><%=order.getUserName()%></td>
        <td><%=order.getContactPhone()%></td>
        <td><%=order.getOrderTime()%></td>
        <td><%=order.getStatus()%></td>
        <td><%=order.getDrinkIds()%></td>
        <td>
            <a href="<%=request.getContextPath()%>/orders/edit?id=<%=order.getId()%>">编辑</a>
            <a href="<%=request.getContextPath()%>/orders/delete?id=<%=order.getId()%>">删除</a>
            <a href="<%=request.getContextPath()%>/orders/update?id=<%=order.getId()%>&newStatus=已完成">完成订单</a>
        </td>
    </tr>
    <%
        }
    } else {
    %>
    <tr>
        <td colspan="7">没有找到匹配的订单。</td>
    </tr>
    <%
        }
    %>
</table>
</body>
</html>